package com.xlh.enums.courseTest;

import com.google.common.base.Objects;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;

/**
 * @author zhr 2019/2/21
 */
@Getter
@AllArgsConstructor
public enum PaperStatusEnum {
    NOT_TEST(1, "未考试"),
    TESTING(2, "正在考试"),
    READING(3, "考试结束"),
    READ(4, "审批结束");

    private final Integer code;
    private final String message;

    private static Map<Integer, PaperStatusEnum> codeLookup = Maps.newHashMap();

    static {
        for (PaperStatusEnum codeEnum : PaperStatusEnum.values()) {
            codeLookup.put(codeEnum.getCode() , codeEnum);
        }
    }

    public static PaperStatusEnum forCode(Integer code) {
        return codeLookup.get(code);
    }

    public boolean notEnd() {
        return Objects.equal(this, NOT_TEST) || Objects.equal(this, TESTING);
    }
}
